#include "global.h"
#include <cassert>
#include <cstring>
#include <utility>

#define MAX_VDISK_SIZE (18205+1)
/* 
Part id range form 0 to 9,[0,9]
Part with id is mapping to id*partsize+1~(id+1)*partsize of virtual disk
*/
class VirtualDisk
{
private:
	int subpart_load[3];
	int first_available_st(int size,int subpartid,int stpoint,int step);
public:
	int V,partsize;
	VirtualDisk(){partsize=V=0;}
	VirtualDisk(int N,int V):partsize(V/(N-1))
	{
		this->V=partsize*N;
		memset(subpart_load, 0, sizeof(subpart_load));
	}

	// Part id range form 0 to 9,[0,9]
	inline int findpart(int x){return (x-1)/partsize;}
	// realdisk id 1~10,realpart id 0~9
	// map the part in virual disk to real disk(repid = 副本编号)
	void mapto_real(int &realdisk,int &realpart,int partid,int subpartid,int repid);
	//the object in position x(and subpart=subpartid)
	void object_in(int &object_id,int &num,int x,int subpartid);
	//线性探测，从stpoint开始，side没用上
	void linear_detector(int object_id,int stpoint,int side,int step);

	inline int vpoint_away(int x,int d){return (x-1+d+V)%V+1;}
};
extern VirtualDisk vdisk;